package cn.bonoon.entities;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import cn.bonoon.kernel.support.entities.AbstractPersistable;

/**
 * <pre>{@link ImmediatePlanEntity}计划下的一个具体的任务；
 * 每次计划都应该把该计划下的任务，即有多少个单位或账户需要处理这个任务的指定清楚，否则没法统计
 * 到期后哪些人没有处理任务
 * 
 * 任务应该是在计划创建时被创建的
 * 任务的具体内容，应该由子类进行定义，并且每个类型的子类，必须定义这个任务的处理方式</pre>
 * @author jackson
 *
 */
@Entity
@Table(name = "t_idttask", catalog = "db_n3pa_idt")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class ImmediateTaskEntity extends AbstractPersistable{

	private static final long serialVersionUID = -299008970651937264L;

	/** 任务所属的计划 */
	@ManyToOne
	@JoinColumn(name = "R_PALN_ID")
	private ImmediatePlanEntity plan;
	
	/** 任务的执行者，一般是ownerid，表示这是一个单位的任务，如果是userid则表示这是一个个人的任务 */
	@Column(name = "C_EXECUTOR")
	private long executor;

	@Enumerated
	@Column(name = "C_TYPE")
	private ImmediateTaskType type = ImmediateTaskType.OWNER;

	@Enumerated
	@Column(name = "C_STATUS")
	private ImmediateTaskStatus status;
	
	@OneToMany(mappedBy = "task")
	private List<ImmediateTaskMaterial> materials;
	
	/** 任务的结束时间来自于计划，但具体的任务可以调整结束时间； */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "C_ENDAT")
	private Date endAt;
	
	/** 任务的创建时间 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "C_CREATEAT", nullable = false)
	private Date createAt;

	@Column(name = "C_CONTENT", length = 1000)
	private String remark;

	public ImmediateTaskStatus getStatus() {
		return status;
	}

	public void setStatus(ImmediateTaskStatus status) {
		this.status = status;
	}

	

	public ImmediatePlanEntity getPlan() {
		return plan;
	}

	public void setPlan(ImmediatePlanEntity plan) {
		this.plan = plan;
	}

	public Date getEndAt() {
		return endAt;
	}

	public void setEndAt(Date endAt) {
		this.endAt = endAt;
	}

	public ImmediateTaskType getType() {
		return type;
	}

	public void setType(ImmediateTaskType type) {
		this.type = type;
	}

	public long getExecutor() {
		return executor;
	}

	public void setExecutor(long executor) {
		this.executor = executor;
	}

	public List<ImmediateTaskMaterial> getMaterials() {
		return materials;
	}

	public void setMaterials(List<ImmediateTaskMaterial> materials) {
		this.materials = materials;
	}

	public Date getCreateAt() {
		return createAt;
	}

	public void setCreateAt(Date createAt) {
		this.createAt = createAt;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
}
